project(TS_PARSER )
cmake_minimum_required(VERSION 3.15)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

#TODO Unify install path on Windows
set(LOCAL_CMAKE_INSTALL_PREFIX "D:/ProgramData/cmake_modules")
set(ANTLR_LIB_PATH "${LOCAL_CMAKE_INSTALL_PREFIX}/lib/cmake/antlr4")
set(Grantlee_PATH "${LOCAL_CMAKE_INSTALL_PREFIX}/Grantlee5")

list(APPEND CMAKE_PREFIX_PATH ${ANTLR_LIB_PATH})
list(APPEND CMAKE_PREFIX_PATH "${Grantlee_PATH}/lib/cmake/Grantlee5")
message(${CMAKE_PREFIX_PATH})

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DCYCLONE_PARSER_DEBUG")
#NOTE -MP flag Disable unnecessary warning for vc
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
    set(CMAKE_CXX_FLAGS "/bigobj /EHsc" )
    set(extra_share_compile_flags "-MP /wd4251")
    set(extra_static_compile_flags "-MP")
    set(disabled_compile_warnings "/wo4530 /wo4251 /wo4838 /wo4530")
endif()

#ANTLR4 
find_package(antlr4-runtime REQUIRED)
find_library(ANTLR4_RUNTIME ${ANTLR4_LIB_DIR})
include_directories( ${ANTLR4_INCLUDE_DIR} )
include_directories( "${Grantlee_PATH}/include" )
include_directories("lib/googletest/googletest/include")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(PARSER_LIBRARY_STATIC true)
set(gtest_force_shared_crt on)

add_subdirectory(code_generator)
add_subdirectory(parser)
add_subdirectory(parser_tree_viewer)
add_subdirectory(gen_embedfile)
add_subdirectory(lib/googletest)


